# 判断点是否在三点内

# 判断 P/A/BC
scoreboard players operation x1 mt_math_cp = xB mt_surf_fill
scoreboard players operation y1 mt_math_cp = yB mt_surf_fill
scoreboard players operation z1 mt_math_cp = zB mt_surf_fill
scoreboard players operation x1 mt_math_cp -= xC mt_surf_fill
scoreboard players operation y1 mt_math_cp -= yC mt_surf_fill
scoreboard players operation z1 mt_math_cp -= zC mt_surf_fill

scoreboard players operation x2 mt_math_cp = xB mt_surf_fill
scoreboard players operation y2 mt_math_cp = yB mt_surf_fill
scoreboard players operation z2 mt_math_cp = zB mt_surf_fill
scoreboard players operation x2 mt_math_cp -= xP mt_surf_fill
scoreboard players operation y2 mt_math_cp -= yP mt_surf_fill
scoreboard players operation z2 mt_math_cp -= zP mt_surf_fill
function mountain:surf_fill/math/cross_product
scoreboard players operation t1 mt_surf_fill = xo mt_math_cp
scoreboard players operation t2 mt_surf_fill = yo mt_math_cp
scoreboard players operation t3 mt_surf_fill = zo mt_math_cp

scoreboard players operation x2 mt_math_cp = xB mt_surf_fill
scoreboard players operation y2 mt_math_cp = yB mt_surf_fill
scoreboard players operation z2 mt_math_cp = zB mt_surf_fill
scoreboard players operation x2 mt_math_cp -= xA mt_surf_fill
scoreboard players operation y2 mt_math_cp -= yA mt_surf_fill
scoreboard players operation z2 mt_math_cp -= zA mt_surf_fill
function mountain:surf_fill/math/cross_product
scoreboard players operation t4 mt_surf_fill = xo mt_math_cp
scoreboard players operation t5 mt_surf_fill = yo mt_math_cp
scoreboard players operation t6 mt_surf_fill = zo mt_math_cp

scoreboard players operation t1 mt_surf_fill *= t4 mt_surf_fill
scoreboard players operation t2 mt_surf_fill *= t5 mt_surf_fill
scoreboard players operation t3 mt_surf_fill *= t6 mt_surf_fill

scoreboard players operation r1 mt_surf_fill = t1 mt_surf_fill
scoreboard players operation r1 mt_surf_fill += t2 mt_surf_fill
scoreboard players operation r1 mt_surf_fill += t3 mt_surf_fill

# 判断 P/B/AC
scoreboard players operation x1 mt_math_cp = xA mt_surf_fill
scoreboard players operation y1 mt_math_cp = yA mt_surf_fill
scoreboard players operation z1 mt_math_cp = zA mt_surf_fill
scoreboard players operation x1 mt_math_cp -= xC mt_surf_fill
scoreboard players operation y1 mt_math_cp -= yC mt_surf_fill
scoreboard players operation z1 mt_math_cp -= zC mt_surf_fill

scoreboard players operation x2 mt_math_cp = xA mt_surf_fill
scoreboard players operation y2 mt_math_cp = yA mt_surf_fill
scoreboard players operation z2 mt_math_cp = zA mt_surf_fill
scoreboard players operation x2 mt_math_cp -= xP mt_surf_fill
scoreboard players operation y2 mt_math_cp -= yP mt_surf_fill
scoreboard players operation z2 mt_math_cp -= zP mt_surf_fill
function mountain:surf_fill/math/cross_product
scoreboard players operation t1 mt_surf_fill = xo mt_math_cp
scoreboard players operation t2 mt_surf_fill = yo mt_math_cp
scoreboard players operation t3 mt_surf_fill = zo mt_math_cp

scoreboard players operation x2 mt_math_cp = xA mt_surf_fill
scoreboard players operation y2 mt_math_cp = yA mt_surf_fill
scoreboard players operation z2 mt_math_cp = zA mt_surf_fill
scoreboard players operation x2 mt_math_cp -= xB mt_surf_fill
scoreboard players operation y2 mt_math_cp -= yB mt_surf_fill
scoreboard players operation z2 mt_math_cp -= zB mt_surf_fill
function mountain:surf_fill/math/cross_product
scoreboard players operation t4 mt_surf_fill = xo mt_math_cp
scoreboard players operation t5 mt_surf_fill = yo mt_math_cp
scoreboard players operation t6 mt_surf_fill = zo mt_math_cp

scoreboard players operation t1 mt_surf_fill *= t4 mt_surf_fill
scoreboard players operation t2 mt_surf_fill *= t5 mt_surf_fill
scoreboard players operation t3 mt_surf_fill *= t6 mt_surf_fill

scoreboard players operation r2 mt_surf_fill = t1 mt_surf_fill
scoreboard players operation r2 mt_surf_fill += t2 mt_surf_fill
scoreboard players operation r2 mt_surf_fill += t3 mt_surf_fill

# 判断 P/C/AB
scoreboard players operation x1 mt_math_cp = xA mt_surf_fill
scoreboard players operation y1 mt_math_cp = yA mt_surf_fill
scoreboard players operation z1 mt_math_cp = zA mt_surf_fill
scoreboard players operation x1 mt_math_cp -= xB mt_surf_fill
scoreboard players operation y1 mt_math_cp -= yB mt_surf_fill
scoreboard players operation z1 mt_math_cp -= zB mt_surf_fill

scoreboard players operation x2 mt_math_cp = xA mt_surf_fill
scoreboard players operation y2 mt_math_cp = yA mt_surf_fill
scoreboard players operation z2 mt_math_cp = zA mt_surf_fill
scoreboard players operation x2 mt_math_cp -= xP mt_surf_fill
scoreboard players operation y2 mt_math_cp -= yP mt_surf_fill
scoreboard players operation z2 mt_math_cp -= zP mt_surf_fill
function mountain:surf_fill/math/cross_product
scoreboard players operation t1 mt_surf_fill = xo mt_math_cp
scoreboard players operation t2 mt_surf_fill = yo mt_math_cp
scoreboard players operation t3 mt_surf_fill = zo mt_math_cp

scoreboard players operation x2 mt_math_cp = xA mt_surf_fill
scoreboard players operation y2 mt_math_cp = yA mt_surf_fill
scoreboard players operation z2 mt_math_cp = zA mt_surf_fill
scoreboard players operation x2 mt_math_cp -= xC mt_surf_fill
scoreboard players operation y2 mt_math_cp -= yC mt_surf_fill
scoreboard players operation z2 mt_math_cp -= zC mt_surf_fill
function mountain:surf_fill/math/cross_product
scoreboard players operation t4 mt_surf_fill = xo mt_math_cp
scoreboard players operation t5 mt_surf_fill = yo mt_math_cp
scoreboard players operation t6 mt_surf_fill = zo mt_math_cp

scoreboard players operation t1 mt_surf_fill *= t4 mt_surf_fill
scoreboard players operation t2 mt_surf_fill *= t5 mt_surf_fill
scoreboard players operation t3 mt_surf_fill *= t6 mt_surf_fill

scoreboard players operation r3 mt_surf_fill = t1 mt_surf_fill
scoreboard players operation r3 mt_surf_fill += t2 mt_surf_fill
scoreboard players operation r3 mt_surf_fill += t3 mt_surf_fill

execute if score r1 mt_surf_fill >= zero mt_surf_fill if score r2 mt_surf_fill >= zero mt_surf_fill if score r3 mt_surf_fill >= zero mt_surf_fill at @e[limit=1,tag=surf_fill_pos] run function mountain:surf_fill/block/entry